Conditions | 8 |
Total Lines | 28 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | class Validate { |
||
42 | paramConfiguration (input, callback) { |
||
43 | let error = null |
||
44 | |||
45 | if (!input.hasOwnProperty('params')) { |
||
46 | if (!error) { |
||
47 | return error = new Error('The parameters are not been set.') |
||
48 | } |
||
49 | } else { |
||
50 | if (!input.params.topic) { |
||
51 | if (!error) { |
||
52 | error = new Error('The parameter topic has not been set.') |
||
53 | } |
||
54 | } |
||
55 | if (!input.params.payload) { |
||
56 | if (!error) { |
||
57 | error = new Error('The parameter payload has not been set.') |
||
58 | } |
||
59 | } |
||
60 | |||
61 | if (![0, 1, 2].includes(input.params.qos)) { |
||
62 | input.params.qos = 1 |
||
63 | } else { |
||
64 | input.params.qos.toString() |
||
65 | } |
||
66 | } |
||
67 | |||
68 | callback(input, error) |
||
69 | } |
||
70 | |||
74 |